--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
sbapp/plyer/tests/test_bluetooth.py 0.2.5 (4af91796) Text, 3.91 KB
T8b949e'''
TestBluetooth
=============
Tested platforms:
* macOS - system_profiler
'''
Tff7b72import T7ee787unittest
Tff7b72from T7ee787plyerT7ee787.T7ee787testsT7ee787.T7ee787common Tff7b72import Te6edf3platform_import
Tff7b72from T7ee787textwrap Tff7b72import Te6edf3dedent
Tff7b72class T56d364MockedSystemProfilerTb4b4b4:
T8b949e'''
Mocked object used instead of Apple's system_profiler
'''
Te6edf3value Tff7b72= Ta5d6ff"Ta5d6ffOnTa5d6ff"
Te6edf3output Tff7b72= Te6edf3dedentTb4b4b4(
T8b949e"""Bluetooth:
Apple Bluetooth Software Version: 6.0.7f11
Hardware, Features, and Settings:
Address: AA-00-BB-11-CC-22
Bluetooth Low Energy Supported: Yes
Handoff Supported: Yes
Instant Hot Spot Supported: Yes
Manufacturer: Broadcom
Transport: UART
Chipset: 1234
Firmware Version: v00 c0000
Bluetooth Power: {}
Auto Seek Pointing: On
Remote wake: On
Vendor ID: 0x0000
Product ID: 0x0000
HCI Version: (0x0)
HCI Revision: 0x0000
LMP Version: (0x0)
LMP Subversion: 0x0000
Auto Seek Keyboard: On
Devices (Paired, Configured, etc.):
iPhone:
Address: AA-00-BB-11-CC-22
Major Type: Miscellaneous
Minor Type: Unknown
Services:
Paired: No
Configured: Yes
Connected: No
Class of Device: 0x00 0x00 0x0000
Services:
Bluetooth File Transfer:
Folder other devices can browse: ~/Public
When receiving items: Accept all without warning
State: Disabled
Bluetooth File Exchange:
Folder for accepted items: ~/Downloads
When other items are accepted: Save to location
When receiving items: Accept all without warning
State: Disabled
Bluetooth Internet Sharing:
State: Disabled
Incoming Serial Ports:
Bluetooth-Incoming-Port:
RFCOMM Channel: 3
Requires Authentication: No"""
Tb4b4b4)Tff7b72.Td2a8ffformatTb4b4b4(Te6edf3valueTb4b4b4)Tff7b72.Td2a8ffencodeTb4b4b4(Ta5d6ff'Ta5d6ffutf-8Ta5d6ff'Tb4b4b4)
Tff7b72def Tff7b72__init__Tb4b4b4(Tff7b72selfTb4b4b4, Tff7b72*Te6edf3argsTb4b4b4, Tff7b72*Tff7b72*Te6edf3kwargsTb4b4b4)Tb4b4b4:
T8b949e# only to ignore all args, kwargs
Tff7b72pass
Tf0883e@staticmethod
Tff7b72def Td2a8ffcommunicateTb4b4b4(Tb4b4b4)Tb4b4b4:
T8b949e'''
Mock Popen.communicate, so that 'system_profiler'
isn't used.
'''
Tff7b72return Tb4b4b4(Te6edf3MockedSystemProfilerTff7b72.Td2a8ffoutputTb4b4b4, Tb4b4b4)
Tf0883e@staticmethod
Tff7b72def Td2a8ffwhereis_exeTb4b4b4(Te6edf3binaryTb4b4b4)Tb4b4b4:
T8b949e'''
Mock whereis_exe, so that it looks like
macOS system_profiler binary is present on the system.
'''
Tff7b72return Te6edf3binary Tff7b72== Ta5d6ff'Ta5d6ffsystem_profilerTa5d6ff'
Tf0883e@staticmethod
Tff7b72def Td2a8ffget_infoTb4b4b4(Tb4b4b4)Tb4b4b4:
T8b949e'''
Return current bluetooth status from mocked output.
'''
Tff7b72return Te6edf3MockedSystemProfilerTff7b72.Td2a8ffvalue
Tff7b72class T56d364TestBluetoothTb4b4b4(Te6edf3unittestTff7b72.Td2a8ffTestCaseTb4b4b4)Tb4b4b4:
T8b949e'''
TestCase for plyer.bluetooth.
'''
Tff7b72def Td2a8fftest_bluetooth_macosxTb4b4b4(Tff7b72selfTb4b4b4)Tb4b4b4:
T8b949e'''
Test macOS system_profiler for plyer.bluetooth.
'''
Te6edf3bluetooth Tff7b72= Te6edf3platform_importTb4b4b4(
Te6edf3platformTff7b72=Ta5d6ff'Ta5d6ffmacosxTa5d6ff'Tb4b4b4,
Te6edf3module_nameTff7b72=Ta5d6ff'Ta5d6ffbluetoothTa5d6ff'Tb4b4b4,
Te6edf3whereis_exeTff7b72=Te6edf3MockedSystemProfilerTff7b72.Td2a8ffwhereis_exe
Tb4b4b4)
Te6edf3bluetoothTff7b72.Td2a8ffPopen Tff7b72= Te6edf3MockedSystemProfiler
Tff7b72selfTff7b72.Td2a8ffassertInTb4b4b4(Ta5d6ff'Ta5d6ffOSXBluetoothTa5d6ff'Tb4b4b4, Tffa657dirTb4b4b4(Te6edf3bluetoothTb4b4b4)Tb4b4b4)
Te6edf3bluetooth Tff7b72= Te6edf3bluetoothTff7b72.Td2a8ffinstanceTb4b4b4(Tb4b4b4)
Tff7b72selfTff7b72.Td2a8ffassertInTb4b4b4(Ta5d6ff'Ta5d6ffOSXBluetoothTa5d6ff'Tb4b4b4, Tffa657strTb4b4b4(Te6edf3bluetoothTb4b4b4)Tb4b4b4)
Tff7b72selfTff7b72.Td2a8ffassertEqualTb4b4b4(
Te6edf3bluetoothTff7b72.Td2a8ffinfoTb4b4b4, Te6edf3MockedSystemProfilerTff7b72.Td2a8ffget_infoTb4b4b4(Tb4b4b4)
Tb4b4b4)
Tff7b72def Td2a8fftest_bluetooth_macosx_instanceTb4b4b4(Tff7b72selfTb4b4b4)Tb4b4b4:
T8b949e'''
Test macOS instance for plyer.bluetooth.
'''
Tff7b72def Td2a8ffno_exeTb4b4b4(Tff7b72*Te6edf3argsTb4b4b4, Tff7b72*Tff7b72*Te6edf3kwargsTb4b4b4)Tb4b4b4:
Tff7b72return
Te6edf3bluetooth Tff7b72= Te6edf3platform_importTb4b4b4(
Te6edf3platformTff7b72=Ta5d6ff'Ta5d6ffmacosxTa5d6ff'Tb4b4b4,
Te6edf3module_nameTff7b72=Ta5d6ff'Ta5d6ffbluetoothTa5d6ff'Tb4b4b4,
Te6edf3whereis_exeTff7b72=Te6edf3no_exe
Tb4b4b4)
Te6edf3bluetooth Tff7b72= Te6edf3bluetoothTff7b72.Td2a8ffinstanceTb4b4b4(Tb4b4b4)
Tff7b72selfTff7b72.Td2a8ffassertNotInTb4b4b4(Ta5d6ff'Ta5d6ffOSXBluetoothTa5d6ff'Tb4b4b4, Tffa657strTb4b4b4(Te6edf3bluetoothTb4b4b4)Tb4b4b4)
Tff7b72selfTff7b72.Td2a8ffassertInTb4b4b4(Ta5d6ff'Ta5d6ffBluetoothTa5d6ff'Tb4b4b4, Tffa657strTb4b4b4(Te6edf3bluetoothTb4b4b4)Tb4b4b4)
Tff7b72if Tff7b72__name__ Tff7b72== Ta5d6ff'Ta5d6ff__main__Ta5d6ff'Tb4b4b4:
Te6edf3unittestTff7b72.Td2a8ffmainTb4b4b4(Tb4b4b4)
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────